
/*
 * GET users listing.
 */

exports.lookup_user_info= function(req, res){
  // res.send("respond with a resource!!");

  var DBPool = req.app.get('DBPool');

  DBPool.getConnection(function(err, conn) {
  	if (err) {
  		throw err;
  	}

    var SQL = "SELECT b.seq, b.socialid, a.uuid, a.nickname, a.shard_Item_db_type FROM info_user a, info_login b WHERE a.user_seq = b.seq";
    
    if ("GID" == req.param('type')) {
      SQL += " AND a.user_seq=" + req.param('value');
    }
    else if ("UUID" == req.param('type')) {
      SQL += " AND a.uuid=" + "'" + req.param('value') + "'";
    }
    else if ("APPID" == req.param('type')) {
      SQL += " AND b.socialid=" + "'" + req.param('value') + "'";
    }
    else {
      SQL += " AND a.nickname=" + "'" + req.param('value') + "'";
    }

  	console.log(SQL);

  	conn.query(SQL, function(err, rows, fields) {
  		conn.release();
  		if (err) {
  			throw err;
  		}

  		res.render('users', { title: req.param('value'), result: rows, fields: fields});
  	});
  });
};